package com.caishi.lkx.user.ienum.type;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author by keray
 * date:2019/7/26 16:01
 * 性别
 */

public enum Sex {
    //
    boy("男", 0),
    girl("女", 1),
    other("其他", 2),
    unknown("未知", 3);

    @Getter
    final
    String desc;

    @Getter
    @EnumValue
    final
    Integer code;

    Sex(String desc, Integer code) {
        this.desc = desc;
        this.code = code;
    }

    public static Sex getSex(String desc){
        return Arrays.stream(Sex.values()).filter(sex -> sex.desc.equals(desc)).findFirst().get();
    }


}
